package com.battle.service.controller.web;

import com.battle.pojo.param.tactics.*;
import com.battle.pojo.param.tacticsUser.CreateTacticsUserParam;
import com.battle.pojo.vo.tactics.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/战术
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/tactics/web")
public class TacticsWebController {

    private final TacticsService service;

    public TacticsWebController(TacticsService service) {
        this.service = service;
    }


    /**
     * 创建战术
     *
     * @param param
     * @return
     */
    @PostMapping("/createTactics")
    public ApiResult createTactics(@RequestBody @Valid CreateTacticsParam param) {
        service.createTactics(param);
        return ApiResult.ok();
    }


    /**
     * 修改战术
     *
     * @param param
     */
    @PutMapping("/editTactics")
    public ApiResult editTactics(@RequestBody @Valid EditTacticsParam param) {
        service.editTactics(param);
        return ApiResult.ok();
    }

    /**
     * 移除战术
     *
     * @param id
     */
    @DeleteMapping("/removeTactics")
    public ApiResult removeTactics(@RequestParam("id") Long id) {
        service.removeTactics(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用战术
     *
     * @param id
     */
    @GetMapping("/enabledTactics")
    public ApiResult enabledTactics(@RequestParam("id") Long id) {
        service.enabledTactics(id);
        return ApiResult.ok();
    }

    /**
     * 获取战术详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getTactics")
    public ApiResult<GetTacticsVo> getTactics(@RequestParam("id") Long id) {
        GetTacticsVo vo = service.getTactics(id);
        return ApiResult.ok(vo);
    }

    /**
     * 创建战术学习
     * @param param
     * @return
     */
    @PostMapping("/createTacticsUser")
    public ApiResult createTacticsUser(@RequestBody @Valid CreateTacticsUserParam param){
        service.createTacticsUser(param);
        return ApiResult.ok();
    }

    /**
     * 获取战术列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getTacticsList")
    public ApiResult<PageResult<GetTacticsListVo>> getTacticsList(@RequestBody GetTacticsListParam param) {
        PageResult<GetTacticsListVo> result = service.getTacticsList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取战术下拉列表
     *
     * @return
     */
    @PostMapping("/getTacticsDownList")
    public ApiResult<List<GetTacticsDownListVo>> getTacticsDownList(@RequestBody(required = false) @Valid GetTacticsDownListParam param) {
        List<GetTacticsDownListVo> list = service.getTacticsDownList(param);
        return ApiResult.ok(list);
    }


}

